<template>
    <view class="content">
        <image :src="info.image_uri || '../../static/icon/avatar.png'" class="avatar" @click="$screenshot('logo',1,1)"></image>
		<view class="box">
			<view class="item" @click="$gTo(`./name?name=${info.nickname}`)">
				<image src="../../static/icon/name.png" class="icon"></image>
				<view>姓名</view>
				<view class="text">{{info.nickname}}</view>
				<u-icon name="arrow-right" color="#a9a9a9" size="28"></u-icon>
			</view>
			<view class="item" @click="$gTo(`./tel?tel=${info.mobile}`)">
				<image src="../../static/icon/tel.png" class="icon"></image>
				<view>手机号</view>
				<view class="text">{{info.mobile}}</view>
				<u-icon name="arrow-right" color="#a9a9a9" size="28"></u-icon>
			</view>
		</view>
    </view>
</template>

<script>
	import {URL} from '@/static/js/common.js'
    export default {
        data() {
            return {
				URL,
                info: {},
            };
        },
        onLoad() {
			let _this = this
            uni.$on('uAvatarCropper', data => {
                _this.$upLoadPic(data.path).then(ret => {
                    console.log(ret)
                    if (data.fromWhere == "logo"){
                        _this.info.image_uri = ret.data.attach_uri
                        _this.info.image_id = ret.data.id
                    }
					if (ret.data.id) {
						_this.$ajax('editInfo', {
						    userToken: _this.$getSync('userToken'),
							image_id: _this.info.image_id,
						}).then(ret => {
							if (ret.status == 0) {
						        _this.$toast('修改头像成功')
							} else {
								// _this.$toast(ret.message);
							}
						});
					}
                });
            })
			uni.$on('EDITINFO', data => {
				this.getInfo()
			})
			
			this.getInfo()
        },
        methods: {
            getInfo() {
            	this.$ajax('members', {
                    userToken: this.$getSync('userToken'),
                }).then(ret => {
            		if (ret.status == 0) {
                        this.info = ret.data
            		} else {
            			this.$toast(ret.message);
            		}
            	});
            },
        }
    };
</script>

<style lang="scss">
    page{
        background-color: #f5f5f5;
    }
	.content{
		padding: 45rpx 25rpx;
	}
	.avatar{
		width: 129rpx;
		height: 129rpx;
		border: 2rpx solid #fff;
		border-radius: 50%;
		margin: 0 auto 50rpx;
	}
	.box{
		padding: 0 30rpx;
		background-color: #fff;
		border-radius: 20rpx;
	}
	.item{
		padding: 30rpx 0;
		display: flex;
		justify-content: space-between;
		align-items: center;
		border-bottom: 2rpx solid #e6e6e6;
		font-size: 32rpx;
	}
	.item:last-child{
		border-bottom: none;
	}
	.icon{
		width: 37rpx;
		height: 37rpx;
		margin-right: 15rpx;
	}
	.text{
		padding: 0 10rpx;
		flex: 1;
		color: #808080;
		text-align: right;
	}
	
	

</style>
